<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>关闭目录句柄</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.closedir" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">closedir</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">closedir</span> &mdash; <span class="dc-title">关闭目录句柄</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.closedir-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>closedir</strong></span>
    ([ <span class="methodparam"><span class="type">resource</span> <code class="parameter">$dir_handle</code></span>
  ] ) : <span class="type"><span class="type void">void</span></span></div>

  <p class="para rdfs-comment">
   关闭由 <code class="parameter">dir_handle</code> 指定的目录流。流必须之前被
   <span class="function"><a href="opendir.html" class="function">opendir()</a></span> 所打开。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.closedir-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">dir_handle</code></dt>

     <dd>

      <p class="para">
       目录句柄的 <span class="type"><a href="language.types.resource.html" class="type resource">resource</a></span>，之前由
       <span class="function"><a href="opendir.html" class="function">opendir()</a></span> 所打开的。如果目录句柄没有指定，那么会假定为是<span class="function"><a href="opendir.html" class="function">opendir()</a></span>所打开的最后一个句柄。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.closedir-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2748">
    <p><strong>Example #1 <span class="function"><strong>closedir()</strong></span> 例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$dir&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"/etc/php5/"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;Open&nbsp;a&nbsp;known&nbsp;directory,&nbsp;read&nbsp;directory&nbsp;into&nbsp;variable&nbsp;and&nbsp;then&nbsp;close<br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">is_dir</span><span style="color: #007700">(</span><span style="color: #0000BB">$dir</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$dh&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">opendir</span><span style="color: #007700">(</span><span style="color: #0000BB">$dir</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$directory&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">readdir</span><span style="color: #007700">(</span><span style="color: #0000BB">$dh</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">closedir</span><span style="color: #007700">(</span><span style="color: #0000BB">$dh</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>

</div></div></div></body></html>